<div id="Users">
{if $showTitle == null}
  <h1>{t}Users list{/t}</h1>
    <div id="moduleTabs">
         <ul>
             <li><a href="{$URL_RELATIVE}/bo/#{$fileLink}" title="{t}Users{/t}"><span>{t}Users{/t}</span></a></li>
         </ul>
    </div>
{/if}
{if $users == null}
    <div class="emptyFolder">
            {icon name="info.png"} {t}There are no users in this folder yet{/t}{hasRight rule=users_Add} - <a href="{$URL_RELATIVE}/bo/#{$addNewUrl}" class="greyButton nyroModal">{t}click here to add a user{/t}</a>{/hasRight}
    </div>
{elseif $users == 'search'}
    <div class="emptyFolder">
        {t}No result{/t} - <a href="{$fileLink}" class="greyButton reload">{t}Click here to return{/t}</a>
    </div>
{else}
{hasRight rule='users_Edit users_Delete'}
<div id="saveButton" style="display:block">
	<div id="selectedelements"></div>
    <ul class="saveButtons">
        {hasRight rule='users_Edit'}
        <li class="first"><a href="{$URL_RELATIVE}/bo/#/?module=users&action=ajaxMoveUser" class="nyroModalResult">{icon name="menu_undo.png"} {t}Move{/t}</a></li>
        {/hasRight}
        {hasRight rule='users_Delete'}
        <li><a href="{$URL_RELATIVE}/bo/#/?module=backoffice&action=AjaxDeleteFolderContent" class="nyroModalResult">{icon name="delete2.png"} {t}Delete{/t}</a></li>
        {/hasRight}
    </ul>
</div>
{/hasRight}
<div id="pagination">{block module="backoffice" action="AjaxPagination" nbDocTot=$pagination.nbDocTot nbDoc=$pagination.nbDoc numPage=$pagination.numPage}</div>
<div id="documentListTableLoader"><div id="loaderPic">{backend_image file="ajax-loader-big.gif"}</div></div>
  <table class="documentListTable">
    <thead>
        <tr>
            {hasRight rule="users_Edit users_Delete"}
            <th><input type="checkbox" class="checkAll select" /></th>
            {/hasRight}
            <th>
                Stat.
            </th>
            <th colspan="2">
                <a href="javascript:void(0);" class="{if $sortParams.column == "login"}{$sortParams.class}{else}no-sort{/if}" title="{if $sortParams.column == "login"}{$sortParams.order}{else}asc{/if}" name="login">
                   {t}Login{/t}
                </a>
            </th>
            <th>
                <a href="javascript:void(0);" class="{if $sortParams.column == "firstname"}{$sortParams.class}{else}no-sort{/if}" title="{if $sortParams.column == "firstname"}{$sortParams.order}{else}asc{/if}" name="firstname">
                    {t}Firstname{/t}
                </a>
            </th>
            <th>
                <a href="javascript:void(0);" class="{if $sortParams.column == "lastname"}{$sortParams.class}{else}no-sort{/if}" title="{if $sortParams.column == "lastname"}{$sortParams.order}{else}asc{/if}" name="lastname">
                   {t}Lastname{/t}
                </a>
            </th>
            <th>
                <a href="javascript:void(0);" class="{if $sortParams.column == "document_creationdate"}{$sortParams.class}{else}no-sort{/if}" title="{if $sortParams.column == "document_creationdate"}{$sortParams.order}{else}asc{/if}" name="document_creationdate">
                    {t}Subscription date{/t}
                </a>
            </th>
        </tr>
        <tr class="searchBar">
            {hasRight rule="users_Edit users_Delete"}
            <th></th>
            {/hasRight}
            <th></th>
            <th colspan="2"><input type="text" name="login" value="{$docSearchParams.login}" /></th>
            <th><input type="text" name="firstname" value="{$docSearchParams.firstname}" /></th>
            <th><input type="text" name="lastname" value="{$docSearchParams.lastname}" /></th>
            <th><input type="text" class="dateInput" name="document_creationdate" value="{$docSearchParams.document_creationdate}" /></th>
        </tr>
    </thead>
    <tbody class="documentListItems">
{foreach from=$users key=num item=value}

      {hasRight rule="users_Edit users_Delete"}
      {if $su->getUniqueId() == $value->getUniqueId() || $currentUser == $value->getUniqueId()}
      <td style="width: 20px; text-align: center;"><input type="checkbox" disabled="disabled" /></td>
      {else}
      <td id="users_Users|{$value->getUniqueId()}|check" style="width: 20px; text-align: center;">
          <input type="checkbox" class="select" value="{$value->getUniqueId()}" name="check_rep[{$num}]" />
      </td>
      {/if}
      {/hasRight}      
      <td style="width: 20px; text-align: center;">
        {assign var='status' value=$value->getPublicationStatus()}
        {hasRight rule=users_Edit}
        {if $su->getUniqueId() != $value->getUniqueId()}
            {publicationStatusSwitch document=$value}
        {else}
            {icon name=status/$status}
        {/if}
        {hasRightElse}
            {icon name=status/$status}
        {/hasRight}
      </td>
      <td style="width: 40px;">
        <span class="listButtons">
            {if $su->getUniqueId() != $value->getUniqueId() && $currentUser != $value->getUniqueId()}
            {hasRight rule=users_Delete}
            <a href="{$URL_RELATIVE}/bo/#{url route='deleteUser' docId=$value->getUniqueId() docLang=$value->getLang()}" class="nyroModal itemButton itemDeleteButton" title="{t}Delete{/t}"></a>
            {/hasRight}
            {/if}
            {hasRight rule=users_Edit}
            <a href="{$URL_RELATIVE}/bo/#{$value->getEditUrl()}" class="openNewWindow itemButton itemEditButton defaultAction"></a>
            {/hasRight}
        </span>
      </td>
      <td id="users_Users|{$value->getUniqueId()}|login">{if $value->getLogin() != ""}{$value->getLogin()}{else}&nbsp;{/if}</td>
      <td id="users_Users|{$value->getUniqueId()}|firstname">{if $value->getFirstname() != ""}{$value->getFirstname()}{else}&nbsp;{/if}</td>
      <td id="users_Users|{$value->getUniqueId()}|lastname">{if $value->getLastname() != ""}{$value->getLastname()}{else}&nbsp;{/if}</td>
      <td id="users_Users|{$value->getUniqueId()}|creation" style="width: 200px;">
        {date date=$value->getCreationDate()}
      </td>
    </tr>
{/foreach}
    </tbody>
  </table>
  <div id="result" style="display: none">&groupId={$group->getUniqueId()}</div>
  <div id="selectResult" style="display: none"></div>
{/if}
</div>

{literal}
<script language="type/javascript">
    column = "{/literal}{$sortParams.column}{literal}";
    order = "{/literal}{$sortParams.order}{literal}";
    searchValues = "{/literal}{$searchParams}{literal}";

    $(document).ready(function(){
        search();
        sort();
    });
</script>
{/literal}